FROM ubuntu:ustc
SHELL ["/bin/bash", "-c"]

ARG UNAME=share
ARG UID=5002
ARG U_PWD=share123456

RUN mkdir -p /srv/vsftp; \
groupadd ${UNAME} -g ${UID}; \
useradd -u ${UID} -g ${UID} ${UNAME} -d /srv/vsftp -s /bin/bash; \
echo "${UNAME}:${U_PWD}" | chpasswd; \
chown ${UNAME}:${UNAME} /srv/vsftp; \
chmod 0775 /srv/vsftp; \
apt-get install -y vsftpd dos2unix; \
apt-get clean ; apt-get autoclean ; apt-get autoremove ; rm -rf /var/lib/apt/lists/* ; 

COPY vsftpd-port.conf /etc/vsftpd-port.conf
COPY vsftpd-pasv.conf /etc/vsftpd-pasv.conf
COPY entrypoint.sh /entrypoint.sh

RUN dos2unix /etc/vsftpd-port.conf; \
dos2unix /etc/vsftpd-pasv.conf; \
rm -f /etc/vsftpd.conf; \
dos2unix /entrypoint.sh; \
chmod +x /entrypoint.sh; \
echo "${UNAME}" >> /etc/vsftpd.userlist

USER root

VOLUME /srv/vsftp
EXPOSE 21

ENTRYPOINT ["/entrypoint.sh"]
CMD ["vsftpd-pasv.conf"]
